//
//  MKUIElementViewBase.h
//  MKUI
//
//  Created by 苏尚进 on 2023/7/10.
//  Copyright © 2023 moon. All rights reserved.
//

#import "MKUIListView.h"
#import "MKUISegmentFlowLayoutConstraint.h"
#import "MKUIFlowLayoutConstraint.h"
#import "MKUILayoutConstraintItemWrapper.h"

NS_ASSUME_NONNULL_BEGIN

@interface MKUIElementViewBase : UIView
@property(nonatomic,readonly) UIView *contentView;
@property(nonatomic,readonly) UIImageView *iconImageView;//左侧的图标
@property(nonatomic,strong,nullable) UIImage *iconImage;//左侧的图标
@property(nonatomic,assign) UIEdgeInsets iconImageMarggin;//默认为0
@property(nonatomic,assign) CGSize iconImageSize;//默认为28x28
@property(nonatomic,assign) BOOL hiddenEmptyIconImage;//是否隐藏空白的图标，默认是YES

@property(nonatomic,readonly) UILabel *titleLabel;//标题
@property(nonatomic,strong,nullable) NSString *titleText;

@property(nonatomic,readonly) UILabel *subTitleLabel;//副标题
@property(nonatomic,strong,nullable) NSString *subTitleText;

@property(nonatomic,strong,nullable) UIView *accessView;//最右侧的操作视图，与contentView同一层
@property(nonatomic,readonly) UIView *disclosureIndicatorAccessView;//向右箭头的accessView
- (UIView *)disclosureIndicatorAccessViewWithColor:(UIColor *)color;
@property(nonatomic,readonly) UIView *checkmarkAccessView;//打勾的accessView
- (UIView *)checkmarkAccessViewWithColor:(UIColor *)color;

@property(nonatomic,assign) UIEdgeInsets contentInsets;//contentView的内边距，默认为UIEdgeInsetsMake(10, 20, 10, 20)
@property(nonatomic,readonly) UIEdgeInsets contentInsetsWithSafeArea;//值为：safeAreaInsets + contentInsets
@property(nonatomic,strong,nullable) MKUILayoutConstraintItemWrapper *iconImageViewLayoutConstraint;//icon的布局约束
@property(nonatomic,strong,nullable) MKUIFlowLayoutConstraint *titlesFlowLayoutConstraint;//title,subtitle的布局约束
@property(nonatomic,strong,nullable) MKUISegmentFlowLayoutConstraint *segLayoutConstraint;//icon,title,subtitle,detail的布局约束

- (CGFloat)titleAndSubTitleHeightThatFits:(CGSize)size;//计算title和subTitle占用的空间高度值
- (CGSize)sizeThatFits:(CGSize)size contentSizeBlock:(CGSize(^)(CGSize contentSize))block;
+ (instancetype)elementWithIconImage:(nullable UIImage *)iconImage titleText:(nullable NSString *)titleText;

- (void)layoutContentView;
@end

@interface UIColor(MKUIElementViewBase)
@property(nonatomic,readonly,class) UIColor *mk_disclosureIndicatorColor;//>箭头的默认颜色值
@end

NS_ASSUME_NONNULL_END

NS_ASSUME_NONNULL_BEGIN
@interface MKUIElementListViewCellBase : MKUIListSelectionCellViewBase
@property(nonatomic,readonly,class,nullable) Class elementViewClass;
@property(nonatomic,readonly,nullable) __kindof MKUIElementViewBase *elementView;
@end
NS_ASSUME_NONNULL_END

#import "MKUITableViewCellBase.h"
#import "NSObject+MKUI.h"
#import "MKUIPreCompile.h"
NS_ASSUME_NONNULL_BEGIN
@interface MKUIElementTableViewCellModelBase : MKUITableViewCellModel
@property(nonatomic,strong,nullable) UIImage *el_iconImage;
@property(nonatomic,assign) UIEdgeInsets el_iconImageMarggin;
- (UIEdgeInsets)el_iconImageMargginWithOtherWise:(UIEdgeInsets)others;

@property(nonatomic,assign) CGSize el_iconImageSize;
- (CGSize)el_iconImageSizeWithOtherWise:(CGSize)others;
@property(nonatomic,assign) BOOL el_hiddenEmptyIconImage;
- (BOOL)el_hiddenEmptyIconImageWithOtherWise:(BOOL)others;

@property(nonatomic,strong,nullable) NSString *el_titleText;
@property(nonatomic,strong,nullable) NSString *el_subTitleText;

@property(nonatomic,assign) UITableViewCellAccessoryType el_accessoryType;
@property(nonatomic,readonly,nullable) __kindof MKUIElementViewBase *el_elementView;

@end
@interface MKUIElementTableViewCellBase : MKUITableViewCellBase
@property(nonatomic,readonly,class,nullable) Class elementViewClass;
@property(nonatomic,readonly,nullable) __kindof MKUIElementViewBase *elementView;
@end
NS_ASSUME_NONNULL_END
